package cn.yunhe.util;

import java.util.List;

public class PageNation<T> {
    private int pageNo;
    private int pageSize;
    private int startRow;
    private int totalRows;
    private int totalPage;
    private int prePage;
    private int nextPage;
    private List<T> items;


    public List<T> getItems() {
        return items;
    }

    public void setItems(List<T> items) {
        this.items = items;
    }

    public int getPageNo() {
        return pageNo;
    }

    public void setPageNo(int pageNo) {
        if (pageNo<=0){
            this.pageNo=1;
        }else{
        this.pageNo = pageNo;
        }
        this.startRow=pageSize*(this.pageNo-1);
    }

    public int getPageSize() {
        return pageSize;
    }

    public void setPageSize(int pageSize) {
        this.pageSize = pageSize;

    }

    public int getStartRow() {
        return startRow;
    }



    public int getTotalRows() {
        return totalRows;
    }

    public void setTotalRows(int totalRows) {
        this.totalRows = totalRows;
        if(totalRows/pageSize==0){
            this.totalPage=totalRows/pageSize;
            if (totalPage==0){
                this.totalPage=1;
            }
        }else {
            this.totalPage=totalRows/pageSize+1;
        }
        if (this.pageNo<=1){
            prePage=1;
        }else {
            prePage=pageNo-1;
        }
        if(this.pageNo>=totalPage){
            this.nextPage=totalPage;
        }else {
            this.nextPage=this.pageNo+1;
        }


    }

    public int getTotalPage() {
        return totalPage;
    }



    public int getPrePage() {
        return prePage;
    }



    public int getNextPage() {
        return nextPage;
    }


}
